<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%-- <base href=" <%=basePath%>"> --%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>购物商城会员注册</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/register_css.css" >
<script type="text/javascript" src="${pageContext.request.contextPath }/javascript/register_js.js"> </script>
</head>
<script type="text/javascript">


function fanHui(){
	window.location.href="login.jsp";
}

function f()
{
	window.location.href="register.jsp";
}

function btn_okClick(){
	var loginId = frm_register.loginId.value;
	if(loginId == ""){
		alert("账号不能为空，请重新输入！");
		frm_register.loginId.focus();//聚焦
		return false;
	}
	if(loginId.length < 6){
		alert("账号不能少于6个字符，请重新输入！")
		frm_register.loginId.select();//回显
		return false;
	}
	if(loginId.length > 20){
		alert("账号不能超过20个字符，请重新输入！")
		frm_register.loginId.select();//回显
		return false;
	}

	var userName = frm_register.userName.value;
	if(userName == ""){
		alert("昵称不能为空，请重新输入！");
		frm_register.userName.focus();//聚焦
		return false;
	}
	if(userName.length > 20){
		alert("昵称不能超过20个字符，请重新输入！")
		frm_register.userName.select();//回显
		return false;
	}

	var realName = frm_register.realName.value;
	if(realName == ""){
		alert("姓名不能为空！");
		frm_register.realName.focus();//聚焦
		return false;
	}

	if(realName.length > 20){
		alert("姓名不能超过20个字符，请重新输入！")
		frm_register.realName.select();//回显
		return false;
	}

	var passwordone = frm_register.passwordone.value;
	var passwordtwo = frm_register.passwordtwo.value;

	if(passwordone == ""){
		alert("密码不能为空！");
		frm_register.passwordone.focus();//聚焦
		return false;
	}

	if(passwordone.length < 6 || passwordone.length > 18 ){

		alert("不合法，请重新输入！");
//		alert("密码不能小于6个字符，请重新输入！");
		frm_register.passwordone.focus();//聚焦
		frm_register.passwordone.select();//回显
		return false;
	}
	if(passwordone.length > 18){
		alert("密码长度不能超过18个字符！")
		frm_register.passwordone.value = "";//清空
		frm_register.passwordone.focus();//聚焦
//		frm_register.passwordone.select();//回显
		return false;
	} 

	if(passwordtwo == ""){
		alert("密码不能为空！");
		frm_register.passwordtwo.focus();//聚焦
		return false;
	}

	if(passwordone != passwordtwo ){
		alert("两次输入密码不一致！");
		frm_register.passwordone.value = "";//清空
		frm_register.passwordtwo.value = "";//清空
		frm_register.passwordone.focus();//聚焦
		return false;
	}

	var email = frm_register.email.value;
	if(email == ""){
		alert("邮箱不能为空！");
		frm_register.email.focus();//聚焦
		return false;
	}

	if(email.length < 6 ){
		alert("邮箱长度不够，请重新输入！")
		frm_register.email.select();//回显
		frm_register.email.focus();//聚焦
		return false;
	}

	if(email.length >= 18){
		alert("邮箱长度过长，请重新输入！")
		frm_register.email.select();//回显
		frm_register.email.focus();//聚焦
		return false;

	}
	if(email != ""&&!/^\w(\w*\.*)*@(\w+\.)+\w{2,4}$/.test(email)){
		alert("邮箱格式不正确!");
		frm_register.email.select();//回显
		frm_register.email.focus();//聚焦
		return false;
	}

	var telephone = frm_register.telephone.value;
	if(telephone == ""){
		alert("电话不能为空！");
		frm_register.telephone.focus();//聚焦
		return false;
	}
	if(telephone.length > 11){
		alert("电话不合法，请重新输入！");
		frm_register.telephone.select();//回显
		frm_register.telephone.focus();//聚焦
		return false;
	}

	var sexNum = document.getElementsByName("gender"); //获取radio对象组，返回值是数组类型的
	var gender = "";  //用于保存用户的选项
	for (var i = 0; i < sexNum.length; ++i) { //循环便利查看用户的选择项
		if (sexNum[i].checked) { //checked代表用户的选择
			gender = sexNum[i]; 
		}
	}
	if (gender == "") { //gender为空代表用户没有选择
		alert("请选择性别!");
		return false;
	} 
	return true;
}

function sub_button (){
//	alert(1)
	var result = btn_okClick();
//	alert(result);
	if(result != false){

		frm_register.submit();//提交表单到服务器
	}
} 

</script>
<body>
	<div id="reg">
		<form action="../Register" method="post" name="frm_register">
			<table align="center">
				<tr>
					<td colspan="2" align="center">用户注册</td>
				</tr>

				<tr>
					<td colspan="2"><input type="text" id="loginId"
						onblur="validateName()" class="input" required="required"
						placeholder="账号" name="loginId" /> <span id="span" class="tip"></span>
					</td>
				</tr>
				<tr>

					<td colspan="2"><input type="text" class="input"
						required="required" placeholder="昵称" name="userName" /> <span
						id="span"
						style="margin-top: 150px; position: absolute; width: 25px;"></span>
					</td>
				</tr>

				<tr>
					<td colspan="2"><input type="text" id="realName"
						onblur="validateName()" class="input" required="required"
						placeholder="姓名" name="realName" /> <span id="span"
						style="margin-top: 150px; position: absolute; width: 25px;"></span>
					</td>
				</tr>

				<!-- required 属性规定必需在提交之前填写输入字段。
如果使用该属性，则字段是必填（或必选）的。
注释：required 属性适用于以下 <input> 类型：text, search, url, telephone, email, password, date pickers, number, checkbox, radio 以及 file。			
	 -->
				<tr>
					<td colspan="2"><input type="password" class="input"
						required="required" placeholder="密码" name="passwordone" /></td>
				</tr>
				<tr>
					<td colspan="2"><input type="password" class="input"
						required="required" placeholder="确认密码" name="passwordtwo" /></td>
				</tr>
				<tr>
					<td colspan="2" align="center"><input type="radio"
						class="radio" name="gender" value="0" checked="true" />男 <input
						type="radio" class="radio" name="gender" value="1" />女</td>
				</tr>

				<tr>
					<td colspan="2"><input type="text" class="input"
						required="required" placeholder="邮箱" name="email"
						onKeyUp="value=value.replace(/[^\w\.\@\/]/ig,'')" /></td>
				</tr>


				<tr>
					<td colspan="2"><input type="text" class="input"
						required="required" placeholder="联系电话" size="11" name="telephone"
						onKeyUp="value=value.replace(/[^\d|chun]/g,'')" maxlength="13" />
					</td>
				</tr>
				<tr>
					<td align="left"><input type="button" class="submit"
						value="提交" onclick="sub_button()" /></td>
					<td align="right"><input type="reset" class="reset" value="重置" />
					</td>
				</tr>
				<tr>
					<td colspan="2"><input type="button"
						onclick="location='Login.jsp'" class="button" title="你已经注册？点击登录"
						value="已经注册？"></td>
				</tr>
			</table>
		</form>
	</div>

</body>
<script>


</script>
</html>